import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import ElementPlus from 'unplugin-element-plus/vite'

//console.log(path.resolve(__dirname, './src'))
// https://vitejs.dev/config/

const pathSrc = path.resolve(__dirname, 'src')
export default defineConfig({
    
    resolve:{
        alias:{
        '~/': `${pathSrc}/`
        }
    },
    css:{
        preprocessorOptions:{
            scss:{
                additionalData: `
@use "~/uiframe/style/vars.scss"  as *;

`
            }
        }
    },
    publicDir: 'public',
    build:{
        outDir:'dist',
        sourcemap:false,
        chunkSizeWarningLimit: 1024
    },
    plugins: [
        vue(),
        AutoImport({
            resolvers: [ElementPlusResolver()],
          }),
          Components({
            resolvers: [ElementPlusResolver()],
          }),
        ElementPlus({
            useSource: true,
        }),
    ],

    server:{
        host:'0.0.0.0',
        proxy:{
            '/api':{
                target:'https://elec.exti.cc',
                changeOrigin:true,
                //rewrite: (path) => path.replace(/^\/api/, '')
            }
        }
    }
})
